﻿#region Using

using Common.Enums;

using GameCommon.Manager;
using GameCommon.ManagerInterfaces;

using Microsoft.Xna.Framework.Graphics;

using GlobalServices = GameCommon.Services.Service;
using Xna = Microsoft.Xna.Framework;

#endregion

namespace Menu.Components
{
    internal class Container : MenuComponentBase
    {
        private Texture2D texture2D;

        public Container(string id, SizeModifier sizeModifier)
            : base(id)
        {
            this.SizeModifier = sizeModifier;
        }

        public Container(string id, MenuComponentBase objectToCopy, SizeModifier sizeModifier)
            : base(id, objectToCopy)
        {
            this.SizeModifier = sizeModifier;
        }

        public Xna.Color BackgroundColor { private get; set; }

        public SizeModifier SizeModifier { get; private set; }

        public override void Draw(IDrawingManager manager, Xna.GameTime gameTime)
        {
            this.DrawingService.Draw(manager, this.texture2D, this.Dimension, this.Opacity, 1);
        }

        public override void Settle()
        {
            base.Settle();

            switch (this.SizeModifier)
            {
                case SizeModifier.FullHeight:
                    this.Dimension.Height = Managers.ContentManager.GetViewportHeight() - this.Dimension.Y;
                    break;
                case SizeModifier.FullWidth:
                    this.Dimension.Width = Managers.ContentManager.GetViewportWidth() - this.Dimension.X;
                    break;
                case SizeModifier.FullWidthAndHeight:
                    this.Dimension.Width = Managers.ContentManager.GetViewportWidth() - this.Dimension.X;
                    this.Dimension.Height = Managers.ContentManager.GetViewportHeight() - this.Dimension.Y;
                    break;
            }

            this.texture2D = Managers.ContentManager.GetRectangle(this.BackgroundColor);
        }

        public override string ToString()
        {
            return string.Format("Container, Id: {0}", this.Id);
        }
    }
}